import { Body, Controller, HttpCode, HttpStatus, Post } from '@nestjs/common';
import { AuthService } from './auth.service';
import { LoginDto, LoginResponseDto } from './dtos/login.dto';
import { RegisterDto, RegisterResponseDto } from './dtos/register.dto';
import { Public } from 'src/decorators/publics.decorator';
import { ApiTags } from '@nestjs/swagger';
import { ApiCommonDataResponse } from 'src/decorators/api-common-data-response.decorator';

@ApiTags('auth')
@Controller('auth')
export class AuthController {
  constructor(private authService: AuthService) {}

  @Public()
  @HttpCode(HttpStatus.OK)
  @Post('login')
  @ApiCommonDataResponse(LoginResponseDto)
  signIn(@Body() loginDto: LoginDto) {
    return this.authService.login(loginDto);
  }

  @Public()
  @HttpCode(HttpStatus.OK)
  @Post('register')
  @ApiCommonDataResponse(RegisterResponseDto)
  register(@Body() registerDto: RegisterDto) {
    return this.authService.register(registerDto);
  }
}
